{include file="header/index" /}

<div class="container whitebg user_management">
    <h4 class="subtitle">共享信息</h4>
    <form class="form-horizontal" id="form">
        <div class="form-group">
            <label class="col-sm-2 control-label">姓名</label>
            <div class="col-sm-4">
                <input type="text" readonly class="form-control" value="{$user_info[0]['username']}">
                <input type="hidden" name="user_id" value="{$user_info[0]['user_id']}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">现在所属区域</label>
            <div class="col-sm-4">
                {volist name="user_info" id="vo"}
                <p>
                    {$vo.company_name}
                </p>
                {/volist}
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">共享所属区域</label>
            <div class="col-sm-3">
                <select id="administrative" name="a_id" class="form-control">
                    {volist name="administrative" id="ad"}
                    <option value="{$ad.a_id}">{$ad.company_name}</option>
                    {/volist}
                </select>
            </div>
        </div>
    </form>
    <div>
        <label class="col-sm-2"></label>
        <button type="button" class="btn btn-primary mr30" id="but">保存</button>
        <button class="btn btn-default" onclick="backurl()">返回</button>
    </div>
</div>

</body>
</html>
<script type="text/javascript">
    //返回上一页
    function backurl() {
        history.back();
    }
    //重置
    function reset(){
        top.layer.confirm('您确认要重置吗？', {
            btn: ['确认','等等'] //按钮
        }, function(){
            $('.form-horizontal')[0].reset();
            top.layer.msg('重置成功', {icon: 1});
        });
    }

    $("#but").click(function () {
        var formData = new FormData($( "#form" )[0]);
        $.ajax({
            url:  "{:url('Customerinfo/Share')}",  /*这是处理文件上传的servlet*/
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            dataType : 'json',
            success: function (returndata) {
                if (returndata.code == 1000) {
                    top.layer.msg(returndata.msg, {icon: 1,time: 2000},function(){
                        history.back();
                    });
                }else{
                    top.layer.msg(returndata.msg, {icon: 2,time: 2000});
                }

            },error: function (returndata) {
                top.layer.msg('数据异常', {icon: 2,time: 2000});
                return false;
            }
        });
    });
</script>